CC = arm-none-eabi-gcc
CFLAGS = -g3 -o0 -mthumb -std=gnu99 -mlittle-endian -mcpu=cortex-m3

RM = rm -f

LINKER_SCT = linker.ld

LDFLAGS = -Wl,-Map=symbolMap.map -T"$(LINKER_SCT)" -nostdlib

TARGET = zOS.elf

OBJS = main.o crt0.o

all: $(TARGET)

%.o : %.c Makefile
	@echo Building File: $<
	@$(CC) $(CFLAGS) -o $@ -c $<

%.o : %.s Makefile
	@echo Building File: $<
	@$(CC) $(CFLAGS) -o $@ -c $<

$(TARGET) : $(OBJS) $(LINKER_SCT)
	@echo Building Target: $@
	@$(CC) $(LDFLAGS) -o $@ $(filter-out %.ld, $^)

clean:
	@$(RM) $(OBJS) $(TARGET) symbolMap.map

.PHONE: all
